<?php
/**
 * tpAdmin [a web admin based ThinkPHP5]
 *
 * @author yuan1994 <tianpian0805@gmail.com>
 * @link http://tpadmin.yuan1994.com/
 * @copyright 2016 yuan1994 all rights reserved.
 * @license http://www.apache.org/licenses/LICENSE-2.0
 */

namespace app\common\model;

use think\Model;
use think\Db;
class AdminPosition extends Model
{

    /**
     * 获得岗位列表
     */
    public function getList($admin_reg){
        $child_plaform = getChildAdminRegByPlaformId($this->plaform);
        $where = ['admin_reg'=>['in',$child_plaform]];
        $arr=$this->field('id,name,pid')->where($where)->select();
        if (!is_array($arr)) return false;
        return $arr;
    }

    /**
     * 通过id获得岗位
     */
    public function getListById($id){
        $arr=$this->field('id,name,pid')->where('id='.$id)->select();
        return $arr;
    }

    public function getListByDepartmentId($id,$admin_reg){
        $child_plaform = getChildAdminRegByPlaformId($this->plaform);
        $where = ['admin_reg'=>['in',$child_plaform]];
        $arr=$this->field('id,name,pid')->where($where)->where('p_status=1 and department_id='.$id)->select();
        return $arr;
    }
}